// pages/message/add/index.js
<<<<<<< HEAD
const $api = require("../../../../api/message").API

=======
>>>>>>> 1c9ce1fdc7fcbf1a028b999eb3cd07f698a8a329
Page({

  /**
   * 页面的初始数据
   */
  data: {
<<<<<<< HEAD
    fileList:[],
    message_title:"",
    message_content:"",
    show:false,
    message_type:"",
    message_type_desc:"",
=======

>>>>>>> 1c9ce1fdc7fcbf1a028b999eb3cd07f698a8a329
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
<<<<<<< HEAD
    var t = this
    t.getMessageTypeList()
  },
  // 选择类型
  settype(){
    var t = this
    t.setData({
      show:true
    })
  },
  // 选中类型
  choosetype(e){
    var t = this
    t.setData({
      message_type:e.detail.value.dict_key,
      message_type_desc:e.detail.value.dict_value
    })
    t.closetype()
  },
  onChangetitle(e){
    var t = this
    t.setData({
      message_title:e.detail
    })
  },
  onChangecontent(e){
    var t = this
    t.setData({
      message_content:e.detail
    })
  },
  // 选择类型
  closetype(){
    var t = this
    t.setData({
      show:false
    })
  },
  // 消息分类列表
  getMessageTypeList(){
    var t = this
    var typelist = wx.getStorageSync('message_type_list')
    if(typelist){
      t.setData({
        typelist:typelist
      })
      return false
    }
    $api.getMessageTypeList().then(res=>{
      wx.setStorageSync('message_type_list', res.data)
      t.setData({
        typelist:res.data
      })
    })
  },
  afterRead(e){
    var t= this
    t.setData({
      fileList:e.detail.file
    })
  },
  deleteimg(e){
    var t = this,
    fileList = t.data.fileList
    fileList.splice(e.detail.index,1)
    t.setData({
      fileList:fileList
    })
  },
  submit(){
    var t = this,
    data = {
      member_id:wx.getStorageSync('user').member_id,
      message_type:t.data.message_type,
      message_title:t.data.message_title,
      message_content:t.data.message_content,
      circle_files:[],
      institution_id:wx.getStorageSync('classinfo').institution_id,
      class_id:wx.getStorageSync('classinfo').class_id,
      grade_id:wx.getStorageSync('classinfo').grade_id,
    }
    $api.saveMessage(data).then(res=>{
      wx.navigateBack({
        delta: 1,
      })
    })
=======

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

>>>>>>> 1c9ce1fdc7fcbf1a028b999eb3cd07f698a8a329
  }
})